% fname: out_matlab/set1_50x50.m
% ../nanoxim -dimx 50 -dimy 50  -disr -cyclelinks 3 -bootstrap center -bootstrap_immunity -bootstrap_timeout 2500 

function [node_coverage, link_coverage, nsegments, avg_seg_length] = set1_50x50(symbol)

data = [
% defective_nodes  node_coverage  link_coverage      nsegments avg_seg_length
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
                0         0.9532       0.950816            883        2.69875
             0.05         0.9504       0.906735            743        3.19785
             0.05         0.9432        0.89449            792        2.97727
             0.05         0.9456       0.896531            756        3.12698
             0.05         0.9544           0.91            790        3.02025
             0.05         0.9512       0.907143            742        3.20485
             0.05         0.9292       0.878776            767        3.02868
             0.05         0.9556       0.913469            572        4.17657
             0.05         0.9388       0.891633            728         3.2239
             0.05         0.9488       0.900408            677        3.50369
             0.05         0.9392       0.889796            593        3.95953
             0.05         0.9496       0.901837            760        3.12368
             0.05          0.942       0.891224            764        3.08246
             0.05          0.946       0.897959            699         3.3834
             0.05         0.9368       0.892245            676         3.4645
             0.05         0.9532       0.909592            783        3.04342
             0.05          0.954       0.907959            744        3.20565
             0.05         0.9468        0.89898            724        3.26934
             0.05         0.9496       0.903061            725        3.27448
             0.05         0.9508       0.904694            701        3.39087
             0.05         0.9548       0.912245            686        3.47959
              0.1         0.8816       0.786122            674        3.27003
              0.1          0.892       0.801837            653        3.41501
              0.1          0.882       0.787755            656        3.36128
              0.1         0.8908       0.799592            621        3.58615
              0.1         0.8784       0.784898            650        3.37846
              0.1         0.9116       0.830612            714        3.19188
              0.1         0.8928       0.807347            701        3.18402
              0.1         0.8868       0.793878            721         3.0749
              0.1         0.8884       0.805714            661        3.36006
              0.1         0.8888       0.796327            689        3.22496
              0.1          0.902       0.817551            678        3.32596
              0.1         0.8988       0.816531            709        3.16925
              0.1          0.892       0.806122            645        3.45736
              0.1         0.8936        0.80898            682        3.27566
              0.1         0.9056       0.828571            722        3.13573
              0.1         0.8892       0.804082            680        3.26912
              0.1         0.8768       0.782449            637        3.44113
              0.1         0.8756       0.783265            576        3.80035
              0.1         0.9072       0.827143            699        3.24464
              0.1         0.8768       0.784898            668        3.28144
             0.15         0.8324       0.720816            539        3.86085
             0.15         0.8368       0.721429            645        3.24341
             0.15         0.8248       0.702857            582        3.54296
             0.15         0.8048       0.693878            541        3.71904
             0.15         0.8216       0.698571            577        3.55979
             0.15         0.8372       0.718367            631        3.31696
             0.15         0.8352       0.717143            692        3.01734
             0.15         0.8588       0.743061            625         3.4352
             0.15         0.8372       0.725918            577        3.62738
             0.15          0.852       0.743878            636        3.34906
             0.15         0.8388       0.723878            622        3.37138
             0.15         0.8316       0.714286            584        3.55993
             0.15         0.8452       0.734286            627        3.37002
             0.15          0.842       0.725918            643        3.27372
             0.15         0.8388       0.719388            635        3.30236
             0.15          0.826           0.71            635        3.25197
             0.15           0.82       0.696122            607        3.37727
             0.15         0.8088       0.688776            585        3.45641
             0.15         0.8424       0.723061            565        3.72743
             0.15         0.8524       0.742245            611        3.48773
              0.2         0.7456        0.60449            525        3.55048
              0.2         0.7404       0.601429            544        3.40257
              0.2         0.7768       0.641224            555         3.4991
              0.2           0.76       0.611224            514         3.6965
              0.2         0.7328       0.587551            496        3.69355
              0.2          0.706       0.580612            451        3.91353
              0.2          0.752       0.620816            538        3.49442
              0.2         0.7332       0.593673            503        3.64414
              0.2         0.7676       0.636327            542        3.54059
              0.2         0.7828       0.647143            556        3.51978
              0.2          0.778       0.633673            523        3.71893
              0.2         0.6524       0.528571            427        3.81967
              0.2          0.732        0.59551            474        3.86076
              0.2         0.7692       0.634286            520        3.69808
              0.2         0.7508       0.608776            519        3.61657
              0.2         0.7304       0.595102            482        3.78838
              0.2         0.7444       0.597755            492        3.78252
              0.2         0.7364       0.587347            472        3.90042
              0.2         0.7404        0.59449            483         3.8323
              0.2         0.7172       0.579796            489        3.66667
             0.25         0.6456       0.492449            425        3.79765
             0.25         0.4072       0.324286            283        3.59717
             0.25         0.5092       0.393061            335            3.8
             0.25         0.6416       0.493061            399        4.02005
             0.25         0.6748       0.528367            454        3.71586
             0.25         0.6632       0.510612            442        3.75113
             0.25          0.618       0.473673            394        3.92132
             0.25         0.0148      0.0114286             10            3.7
             0.25         0.6484       0.501224            414        3.91546
             0.25          0.024      0.0177551             15              4
             0.25         0.5104        0.39102            334        3.82036
             0.25         0.0052     0.00367347              5            2.6
             0.25          0.474       0.371224            336        3.52679
             0.25         0.0056     0.00387755              3        4.66667
             0.25         0.6672        0.51898            440        3.79091
             0.25         0.6796       0.534082            466        3.64592
             0.25         0.5888        0.44898            362         4.0663
             0.25         0.6652       0.517959            412        4.03641
             0.25         0.6368        0.48898            426        3.73709
             0.25         0.6928       0.538367            451        3.84035
              0.3         0.6052       0.454286            375        4.03467
              0.3         0.0672      0.0510204             38        4.42105
              0.3         0.4216       0.308367            254        4.14961
              0.3          0.174       0.131224            104        4.18269
              0.3         0.2592       0.192041            163        3.97546
              0.3         0.2676       0.198367            175        3.82286
              0.3         0.0108     0.00734694              7        3.85714
              0.3         0.2776       0.208776            190        3.65263
              0.3         0.4212       0.316939            275        3.82909
              0.3         0.2692       0.197755            165        4.07879
              0.3          0.008      0.0055102              6        3.33333
              0.3         0.4072       0.302857            247        4.12146
              0.3         0.5672       0.425102            349        4.06304
              0.3         0.5368        0.39898            326        4.11656
              0.3          0.304       0.228163            216        3.51852
              0.3         0.1856       0.139184            124        3.74194
              0.3         0.1888       0.141224            124        3.80645
              0.3         0.0088     0.00653061              9        2.44444
              0.3         0.4508       0.329592            265        4.25283
              0.3          0.114      0.0836735             73        3.90411
             0.35         0.1672       0.120816            114        3.66667
             0.35         0.0724      0.0502041             48        3.77083
             0.35         0.0728      0.0520408             42        4.33333
             0.35         0.2492       0.182245            152        4.09868
             0.35         0.0872      0.0628571             57        3.82456
             0.35         0.0032     0.00204082              2              4
             0.35         0.0128     0.00857143              5            6.4
             0.35         0.0476       0.034898             31        3.83871
             0.35          0.064       0.045102             42        3.80952
             0.35          0.238       0.168163            127        4.68504
             0.35         0.0488      0.0359184             34        3.58824
             0.35         0.3684       0.266122            220        4.18636
             0.35         0.1136      0.0802041             64         4.4375
             0.35          0.044      0.0322449             29         3.7931
             0.35         0.0056     0.00408163              5            2.8
             0.35         0.0128     0.00918367              6        5.33333
             0.35         0.0324      0.0214286             13        6.23077
             0.35         0.0128     0.00938776             11        2.90909
             0.35          0.164       0.117347             95        4.31579
             0.35         0.0016    0.000816327              1              4
              0.4         0.0016    0.000816327              1              4
              0.4         0.0092     0.00632653              6        3.83333
              0.4         0.0428      0.0297959             21        5.09524
              0.4         0.0032     0.00204082              2              4
              0.4         0.0176      0.0116327              9        4.88889
              0.4         0.0044     0.00285714              4           2.75
              0.4         0.0032     0.00204082              2              4
              0.4         0.0032     0.00204082              3        2.66667
              0.4         0.0868      0.0591837             46        4.71739
              0.4         0.0164      0.0116327             14        2.92857
              0.4          0.028      0.0195918             21        3.33333
              0.4         0.0108      0.0077551              8          3.375
              0.4          0.014     0.00918367             10            3.5
              0.4         0.0064     0.00469388              5            3.2
              0.4          0.042      0.0316327             33        3.18182
              0.4          0.008      0.0055102              5              4
              0.4         0.0024     0.00142857              2              3
              0.4         0.0016    0.000816327              1              4
              0.4          0.006     0.00428571              6            2.5
              0.4         0.0056     0.00346939              4            3.5
             0.45         0.0108     0.00653061              5            5.4
             0.45         0.0036      0.0022449              1              9
             0.45         0.0064     0.00408163              2              8
             0.45         0.0048     0.00326531              4              3
             0.45         0.0028     0.00163265              1              7
             0.45         0.0864      0.0579592             43        5.02326
             0.45         0.0128     0.00857143              8              4
             0.45         0.0056     0.00408163              5            2.8
             0.45         0.0108     0.00795918              6            4.5
             0.45          0.004     0.00265306              3        3.33333
             0.45         0.0228      0.0155102             14        4.07143
             0.45         0.0064      0.0044898              4              4
             0.45         0.0068     0.00469388              5            3.4
             0.45         0.0524      0.0371429             29        4.51724
             0.45          0.016      0.0114286             11        3.63636
             0.45         0.0068     0.00469388              5            3.4
             0.45          0.004     0.00265306              2              5
             0.45         0.0056     0.00387755              5            2.8
             0.45         0.0132     0.00816327              4           8.25
             0.45         0.0104     0.00714286              7        3.71429
              0.5         0.0048     0.00326531              4              3
              0.5         0.0232      0.0181633             24        2.41667
              0.5         0.0096     0.00653061              7        3.42857
              0.5         0.0016    0.000816327              1              4
              0.5         0.0032     0.00204082              2              4
              0.5          0.004     0.00265306              3        3.33333
              0.5         0.0024     0.00142857              1              6
              0.5          0.006     0.00387755              4           3.75
              0.5         0.0024     0.00142857              1              6
              0.5         0.0068     0.00469388              5            3.4
              0.5         0.0072     0.00469388              4            4.5
              0.5         0.0004              0              1              1
              0.5         0.0016    0.000816327              1              4
              0.5         0.0024     0.00142857              2              3
              0.5          0.004     0.00265306              4            2.5
              0.5          0.004     0.00265306              3        3.33333
              0.5         0.0016    0.000816327              1              4
              0.5         0.0024     0.00142857              2              3
              0.5         0.0072     0.00510204              6              3
              0.5         0.0032     0.00204082              2              4
];

rows = size(data, 1);
cols = size(data, 2);

node_coverage = [];
for i = 1:rows/20,
   ifirst = (i - 1) * 20 + 1;
   ilast  = ifirst + 20 - 1;
   tmp = data(ifirst:ilast, cols-4+1);
   avg = mean(tmp);
   [h sig ci] = ttest(tmp, 0.1);
   ci = (ci(2)-ci(1))/2;
   node_coverage = [node_coverage; data(ifirst, 1:cols-4), avg ci];
end

figure(1);
hold on;
title('Node Coverage')
plot(node_coverage(:,1), node_coverage(:,2), symbol);
ylim([0 1])
xlabel('Node Defect Rate')
ylabel('node_coverage')


